import { loadEnv, type ConfigEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

export default ({ command, mode }: ConfigEnv) => {
  const isBuild = command == "build";
  const root = process.cwd();
  const env = loadEnv(mode, root);

  return {
    plugins: [vue()],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
        "#": path.resolve(__dirname, "types"),
      },
    },
    server: {
      host: true,
      port: 3000,
      open: true,
      proxy: {
        "/api": {
          target: env.VITE_API_URL,
          changeOrigin: true,
        },
      },
    },
  };
};
